<?php
/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-27
 * Time: 上午10:01
 * To change this template use File | Settings | File Templates.
 */

namespace AuctionCore\AuctionOrder;


class AuctionSettingTest extends \PHPUnit_Framework_TestCase {
      function testAdd(){
               try{
                   $a = new AuctionSetting();
                   $data = array();
                   $data['name'] = 'TRANSFER_FEE';
                   $data['type'] = '1';
                   $data['title'] = '过户费';
                   $data['group'] = '1';
                   $data['extra'] = '额外说明';
                   $data['remark'] = '配置说明';
                   $data['status'] = '1';
                   $data['value'] = '1000';
                   $data['sort'] = '1';
                   $res = $a->add($data);
               }catch (\Exception $e){
                   echo $e->getMessage();
                   $res = false;
               }
               $this->AssertTrue($res?true:false);
      }
      function testEdit(){
                $a = new AuctionSetting();
                $data = array();
                $data['id'] = '60';
                $data['name'] = 'COMMISSION_FEE';
                $data['type'] = '2';
                $data['title'] = '佣金';
                $data['group'] = '2';
                $data['extra'] = '额外说明1';
                $data['remark'] = '配置说明1';
                $data['status'] = '2';
                $data['value'] = '2000';
                $data['sort'] = '2';
                try{
                   $res = $a->edit($data);
                }catch (\Exception $e){
                   echo $e->getMessage();
                   $res = false;
                }
               $this->AssertTrue(true);
      }
      function testUpdate(){
                $a = new AuctionSetting();
                $data = array();
                $data['value'] = '3000';
                $cond = "name='COMMISSION_FEE'";
                try{
                   $a->update($cond,$data);
                   $c = $a->detail('60');
                   $res = $c['value'] =='3000' ?  true :false;
                }catch (\Exception $e){
                   echo $e->getMessage();
                   $res = false;
                }

               $this->AssertTrue($res?true:false);
      }
      function testDetail(){
                $a = new AuctionSetting();
                $id = M('setting')->max('id');
                try{
                   $res = $a->detail($id);
                   dump($res);
                }catch (\Exception $e){
                   echo $e->getMessage();
                   $res = false;
                }
               $this->AssertTrue($res?true:false);
      }
      function testDel(){
                $a = new AuctionSetting();
                $id = '59';
                try{
                   $res = $a->del($id);
                }catch (\Exception $e){
                   echo $e->getMessage();
                   $res = false;
                }
               $this->AssertTrue($res?true:false);
      }
}
